package com.oracle.lingshangejia.fragment;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.oracle.lingshangejia.R;

import com.oracle.lingshangejia.activity.ArchivesActivity;
import com.oracle.lingshangejia.activity.ResidentActivity;
import com.oracle.lingshangejia.activity.TakingRecordsActivity;
import com.oracle.lingshangejia.base.BaseFragment;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;



public class FileFragment extends BaseFragment implements View.OnClickListener {
    private ImageButton ib_file_add;
    private LinearLayout ll_resident_file;//居民档案
    private LinearLayout ll_sx; //双向转诊
    private TagFlowLayout mFlowLayout; //标签
    private ArrayList<String> titlelist=new ArrayList<>();
    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {

        final LayoutInflater mInflater = LayoutInflater.from(getActivity());
        mFlowLayout.setAdapter(new TagAdapter<String>(titlelist)
        {

            @Override
            public View getView(FlowLayout parent, int position, String s)
            {
                TextView tv = (TextView) mInflater.inflate(R.layout.tv,
                        mFlowLayout, false);
                tv.setText(s);
                return tv;
            }
        });
    }

    @Override
    protected void onBindViewBefore(View view) {
        mFlowLayout=view.findViewById(R.id.id_flowlayout);
        ib_file_add=view.findViewById(R.id.ib_file_add);
        ll_resident_file=view.findViewById(R.id.ll_resident_file);
        ll_sx=view.findViewById(R.id.ll_sx);
        ib_file_add.setOnClickListener(this);
        ll_resident_file.setOnClickListener(this);
        ll_sx.setOnClickListener(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_file;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ib_file_add:  //添加档案
                startActivity(new Intent(getActivity(),ArchivesActivity.class));
                break;
            case R.id.ll_resident_file://居民档案
                startActivity(new Intent(getActivity(), ResidentActivity.class));
                break;
            case R.id.ll_sx:  //接诊记录
                startActivity(new Intent(getActivity(),TakingRecordsActivity.class));
                break;
        }
    }
}
